package com.xyy.saas.payment.payment.core.bo;


import com.xyy.saas.payment.common.enums.FBankTradeStatusEnum;
import com.xyy.saas.payment.cores.enums.YopTradeStatusEnum;
import com.xyy.saas.payment.dao.model.WithdrawOrder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wangtianqi
 * @date 2019/10/28 16:13
 */
@Getter
@Setter
public class WithdrawalBO implements Serializable {

    private static final long serialVersionUID = -6598814985056701882L;
    /**
     * 渠道提现单号
     */
    private String channelWithdrawNo;
    /**
     * 提现商家名称
     */
    private String userName;
    /**
     * 提现状态
     */
    private String status;
    /**
     * 交易完成时间
     */
    private String finishTime;
    /**
     * 需要鉴权
     */
    private Boolean needAuth = Boolean.FALSE;
    /**
     * 支付平台提现单号
     */
    private String withdrawalNo;

    /**
     * 是否需要主动回调业务
     */
    public boolean needNotice() {
        return String.valueOf(WithdrawOrder.STATUS_FINISH).equals(status) ||
                String.valueOf(WithdrawOrder.STATUS_FAIL).equals(status)  ||
                FBankTradeStatusEnum.FAILURE.name().equals(status) ||
                FBankTradeStatusEnum.SUCCESS.name().equals(status) ||
                YopTradeStatusEnum.FAIL.name().equals(status)
                ;
    }

    /**
     * 主动回调业务参数
     */
    public Map<String, String> noticeParam() {
        Map<String, String> param = new HashMap<>();
        param.put("status", status);
        param.put("withdrawNo", withdrawalNo);
        return param;
    }

    /**
     * 提现成功
     */
    public static boolean success(String status) {
        return String.valueOf(WithdrawOrder.STATUS_FINISH).equals(status) ||
                FBankTradeStatusEnum.SUCCESS.name().equals(status);
    }

    /**
     * 提现退汇
     */
    public static boolean refund(String status) {
        return String.valueOf(WithdrawOrder.STATUS_REFUND).equals(status) ||
                FBankTradeStatusEnum.RE_EXCHANGED.name().equals(status);
    }
}
